package list.test;

import java.io.*;

/**
 * @author PC
 * @date 2020/5/18
 */
public class SerializableTest1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        writeObject();
        readObject();
    }
    public static void writeObject() throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("obj.txt"));
        Student s1 = new Student("张三",23);
        oos.writeObject(s1);
        oos.close();
    }
    public static void readObject() throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("obj.txt"));
        Student o = (Student) ois.readObject();
        ois.close();
        System.out.println(o);
    }
}
